package org.example.controller;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bw.springboot.starter.upload.model.Chunk;
import com.bw.springboot.starter.upload.service.FileService;
import com.bw.springboot.starter.upload.util.FileResult;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.example.config.PageBean;
import org.example.config.ZzyUtils;
import org.example.entity.*;
import org.example.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.*;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhaowenting
 * @since 2024-03-27
 */
@RestController
@RequestMapping("/sys-crop")
public class SysCropController {
    @Autowired
    IPayPlanService iPayPlanService;
    @Autowired
    ISysGoodsService iSysGoodsService;
    @Autowired
    private ISysLogisticsService iSysLogisticsService;
    @Autowired
    ITbUserService iTbUserService;
    @Autowired
    FileService fileService;
    @Autowired
    HttpServletRequest request;
    @Autowired
    IAdviseTransportService iAdviseTransportService;
    @Autowired
    ISysManufacturerService iSysManufacturerService;
    @Autowired
    ISysDeiversService iSysDeiversService;
    @Autowired
    ISysCropService iSysCropService;
    @Autowired
    ISysDictionaryService iSysDictionaryService;
    @Autowired
    ISysHouseholdService iSysHouseholdService;
    @Autowired
    ICycleCordService iCycleCordService;
    @Autowired
    RedisTemplate redisTemplate;
    @Autowired
    ISysLogisticsXxljobService iSysLogisticsXxljobService;
    /**
     * 农作物列表
     * @return
     */
    @RequestMapping("cropList")
    public PageInfo<SysCrop> cropList(@RequestBody PageBean pageBean){
        PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize());
        List<SysCrop> list = iSysCropService.listAll();
        final PageInfo<SysCrop> sysCropPageInfo = new PageInfo<>(list);
        return sysCropPageInfo;
    }

    /**
     * 作物类型列表
     * 从字典表里查询
     * @return
     */
    @RequestMapping("cropTypeList")
    public Object cropTypeList(){
        LambdaQueryWrapper<SysDictionary> sysDictionaryLambdaQueryWrapper = new LambdaQueryWrapper<>();
        sysDictionaryLambdaQueryWrapper.eq(SysDictionary::getSysType,"sys_crop_type");
        List<SysDictionary> list = iSysDictionaryService.list(sysDictionaryLambdaQueryWrapper);
        return list;
    }
    /**
     * 种植方式列表
     */
    @RequestMapping("plantTypeList")
    public Object plantTypeList(){
        final LambdaQueryWrapper<SysDictionary> sysDictionaryLambdaQueryWrapper = new LambdaQueryWrapper<>();
        sysDictionaryLambdaQueryWrapper.eq(SysDictionary::getSysType,"sys_crop_plant");
        final List<SysDictionary> list = iSysDictionaryService.list(sysDictionaryLambdaQueryWrapper);
        return list;
    }

    /**
     * 是否套袋列表
     * @return
     */

    @RequestMapping("baggingList")
    public Object baggingList(){
        LambdaQueryWrapper<SysDictionary> sysDictionaryLambdaQueryWrapper = new LambdaQueryWrapper<>();
        sysDictionaryLambdaQueryWrapper.eq(SysDictionary::getSysType,"sys_crop_bagging");
        List<SysDictionary> list = iSysDictionaryService.list(sysDictionaryLambdaQueryWrapper);
        return list;
    }
    /**
     * 新增作物
     */
    @RequestMapping("addCrop")
    public String addCrop(@RequestBody SysCrop sysCrop){
        sysCrop.setCropNumbering(IdUtil.getSnowflake().nextIdStr());
        sysCrop.setCreateTime(new Date());
        iSysCropService.save(sysCrop);
        return "success";
    }
    /**
     * 农户列表
     */
    @RequestMapping("householdList")
    public List<SysHousehold> householdList(){
        final List<SysHousehold> list = iSysHouseholdService.list();
        return list;
    }
    /**
     * 添加农户
     */
    @RequestMapping("addHousehold")
    public String addHousehold(@RequestBody SysHousehold sysHousehold){
        iSysHouseholdService.save(sysHousehold);
        return "success";
    }
    /**
     * 根据前端传过来的作物ID去关联农户
     */
    @RequestMapping("getByIdCrop")
    public SysCrop getByIdCrop(Integer id){
        List<SysCrop> list=iSysCropService.getByIdCrop(id);
        return list.get(0);
    }
    /**
     * 大文件上传
     *//*
    @RequestMapping("upload")
    public Object upload(Chunk chunk) throws InterruptedException {
        int i = fileService.postFileUpload(chunk);
        if(chunk.getTotalChunks().equals(chunk.getChunkNumber())){
            TimeUnit.SECONDS.sleep(3);
            FileResult fileResult = fileService.mergeFile(chunk);
            return fileResult;
        }
        return i==1?"success":"error";
    }*/

    /**
     * 添加周期记录
     * @param cycleCord
     * @return
     */
    @RequestMapping("addCycleRecord")
    public String addCycleRecord(@RequestBody CycleCord cycleCord){
        cycleCord.setCreateTime(new Date());
        String  o = (String) redisTemplate.opsForValue().get("images");
        cycleCord.setImg(o);
        System.out.println("前端传过来的周期数据："+cycleCord);
        iCycleCordService.save(cycleCord);
        return "success";
    }

    /**
     * 根据id 查询作物表和周期表所关联的数据
     * @param cropNumbering
     * @return
     */
    @RequestMapping("processDetails")
    public List<CycleCord> processDetails(String cropNumbering){
        System.out.println("前端传过来的作物编号:"+cropNumbering);
        LambdaQueryWrapper<CycleCord> cycleCordLambdaQueryWrapper = new LambdaQueryWrapper<>();
        cycleCordLambdaQueryWrapper.eq(CycleCord::getCropNumbering,cropNumbering);
        List<CycleCord> list = iCycleCordService.list(cycleCordLambdaQueryWrapper);
        return list;
    }
    /**
     * 获取空闲状态的司机列表
     */
    @RequestMapping("getDeiversList")
    public List<SysDeivers> getDeiversList(){
        final LambdaQueryWrapper<SysDeivers> sysDeiversLambdaQueryWrapper = new LambdaQueryWrapper<>();
        sysDeiversLambdaQueryWrapper.eq(SysDeivers::getState,1);
        List<SysDeivers> list = iSysDeiversService.list(sysDeiversLambdaQueryWrapper);
        return list;
    }
    /**
     * 查询所有的司机列表
     */
    @RequestMapping("getAllDeiversList")
    public List<SysDeivers> getAllDeiversList(){
        final List<SysDeivers> list = iSysDeiversService.list();
        return list;
    }
    /**
     * 厂家列表方法
     */
    @RequestMapping("getManufacturerList")
    public List<SysManufacturer> getManufacturerList(){
        final List<SysManufacturer> list = iSysManufacturerService.list();
        return list;
    }
    /**
     *  新增通知运输方法
     */
    @RequestMapping("addAdvise")
    public String addAdvise(@RequestBody AdviseTransport adviseTransport){
        iAdviseTransportService.save(adviseTransport);
        //根据农作物id去查询作物表
        //修改作物状态为待运输
        SysCrop byId = iSysCropService.getById(adviseTransport.getCropId());
        byId.setSysTypeState(4);
        iSysCropService.updateById(byId);
        /*//根据绑定的司机id去查询司机表 修改司机状态
        SysDeivers sysDeivers = iSysDeiversService.getById(adviseTransport.getDeiversId());
        sysDeivers.setState(25);
        iSysDeiversService.updateById(sysDeivers);*/
        //修改完成后再去添加物流表
        SysLogistics sysLogistics = new SysLogistics();
        sysLogistics.setCreateTime(new Date());
        //登录人
        String username = (String) redisTemplate.opsForValue().get("username");
        System.err.println("登录人为：===="+username);
        //将物流表的状态修改为待通知
        sysLogistics.setLogisticsNotifier(username);
        sysLogistics.setState(5);
        //根据adviseTransport中关联的作物cropId去获取作物的编号
        sysLogistics.setLogisticsNumber(byId.getCropNumbering());
        sysLogistics.setDeiverId(adviseTransport.getDeiversId());
        sysLogistics.setRemark(adviseTransport.getRemark());
        final LambdaQueryWrapper<TbUser> tbUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
        tbUserLambdaQueryWrapper.eq(TbUser::getUsername,username);
        TbUser dbuser = iTbUserService.getOne(tbUserLambdaQueryWrapper);
        System.err.println("登录人的信息为：======="+dbuser);
        sysLogistics.setNotifierPost(dbuser.getPosts());
        iSysLogisticsService.save(sysLogistics);
        return "success";
    }
    /**
     * 获取地址
     */
    @RequestMapping("getAddr")
    public AdviseTransport getAddr(Integer id){
        AdviseTransport adviseTransport=iAdviseTransportService.getAddr(id);
        return adviseTransport;
    }
    /**
     * 视频文件图片上传
     */
    @RequestMapping("upload")
    public Object upload(Chunk chunk) throws InterruptedException {
        final int i = fileService.postFileUpload(chunk);
        System.out.println("ssss"+i);
        if(chunk.getTotalChunks().equals(chunk.getChunkNumber())){
            TimeUnit.SECONDS.sleep(3);
            final FileResult fileResult = fileService.mergeFile(chunk);
            String fileUrl = fileResult.getFileUrl();
            System.out.println("上传路径为："+fileUrl);
            redisTemplate.opsForValue().set("images",fileUrl);
            return fileResult;
        }
        return i==1?"success":"error";
    }
    /*新增司机方法*/
    @RequestMapping("addDriver")
    public String addDriver(@RequestBody SysDeivers sysDeivers){
        System.out.println("前端传过来的司机数据：===="+sysDeivers);
        iSysDeiversService.saveOrUpdate(sysDeivers);

        return "success";
    }
    /**
     * 删除司机
     * 根基ID单删
     */
    @RequestMapping("deleteDriver")
    public String deleteDriver(Integer id){
        iSysDeiversService.removeById(id);
        return "success";
    }

    /**
     * 根据id查询司机
     * @param id
     * @return
     */
    @RequestMapping("getByIdOneDriver")
    public SysDeivers getByIdOneDriver(Integer id){
        SysDeivers byId = iSysDeiversService.getById(id);
        return byId;
    }
    /**
     * 上传司机头像
     */
    @RequestMapping("uploadDriverAvatar")
    public String uploadDriverAvatar(MultipartFile file) throws IOException {
        String originalFilename = file.getOriginalFilename();
        String substring = originalFilename.substring(originalFilename.lastIndexOf("."), originalFilename.length());
        System.out.println("图片类型为:=="+substring);
        String filename=UUID.randomUUID()+substring;
        file.transferTo(new File("/Users/zhaowenting/Desktop/upload/pic/"+filename));
        return "http://172.20.10.5:8084/goods/upload/pic/"+filename;
    }
    /*查询所有物流方法*/
    @RequestMapping("logisticsList")
    public List<SysLogistics> logisticsList(){
        final List<SysLogistics> list = iSysLogisticsService.listAll();
        return list;
    }

    /**
     * 通知司机按钮
     * @param sysLogistics
     * @return
     */
    @RequestMapping("informDeiver")
    public String informDeiver(@RequestBody SysLogistics sysLogistics){
        System.err.println("前端传过来的物流信息:=="+sysLogistics);
        //根据sysLogisticsXxljob中的司机编号deiverId去获取司机的手机号去发短信
        SysDeivers sysDeiversServiceById = iSysDeiversService.getById(sysLogistics.getDeiverId());
        //司机手机号
        String phone = sysDeiversServiceById.getPhone();
        //根据手机号去发送消息
        boolean b = ZzyUtils.sendSms(phone, "您有一个订单");
        System.out.println("000000000"+b);
        //如果消息发送成功，则修改物流表状态为已通知
        if(b==true){
            //将前端的数据添加到物流日志表中
            SysLogisticsXxljob sysLogisticsXxljob = BeanUtil.copyProperties(sysLogistics, SysLogisticsXxljob.class);
            iSysLogisticsXxljobService.save(sysLogisticsXxljob);
            /*sysDeiversServiceById.setState(25);
            iSysDeiversService.updateById(sysDeiversServiceById);
            //把物流表里的状态改为已通知
            sysLogistics.setState(29);
            iSysLogisticsService.updateById(sysLogistics);
            sysLogisticsXxljob.setState(29);
            iSysLogisticsXxljobService.updateById(sysLogisticsXxljob);
            return "success";*/
            final LambdaQueryWrapper<SysCrop> sysCropLambdaQueryWrapper = new LambdaQueryWrapper<>();
            sysCropLambdaQueryWrapper.eq(SysCrop::getCropNumbering,sysLogistics.getLogisticsNumber());
            SysCrop sysCrop = iSysCropService.getOne(sysCropLambdaQueryWrapper);
            final LambdaQueryWrapper<AdviseTransport> adviseTransportLambdaQueryWrapper = new LambdaQueryWrapper<>();
            adviseTransportLambdaQueryWrapper.eq(AdviseTransport::getCropId,sysCrop.getId());
            adviseTransportLambdaQueryWrapper.eq(AdviseTransport::getState,5);
            AdviseTransport adviseTransport = iAdviseTransportService.getOne(adviseTransportLambdaQueryWrapper);
            adviseTransport.setState(6);
            iAdviseTransportService.updateById(adviseTransport);
            sysLogistics.setState(6);
            iSysLogisticsService.updateById(sysLogistics);
            sysLogisticsXxljob.setState(6);
            iSysLogisticsXxljobService.updateById(sysLogisticsXxljob);
            return "success";
        }
        return "error";
    }

    public static void main(String[] args) {

        boolean b = ZzyUtils.sendSms("19232210048", "1111");
        System.out.println(b);
    }

    //在线用户
    @RequestMapping("onlineUser")
    public String onlineUser() throws UnknownHostException {

        return "success";
    }

    /**
     * 消息列表
     * 根据用户id去查询物流表
     * @param userId
     * @return
     */
    @RequestMapping("messageList")
    public Object messageList(Integer userId){
        TbUser tbUser = iTbUserService.getById(userId);
        LambdaQueryWrapper<SysDeivers> sysDeiversLambdaQueryWrapper = new LambdaQueryWrapper<>();
        sysDeiversLambdaQueryWrapper.eq(SysDeivers::getName,tbUser.getUsername());
        SysDeivers sysDeivers = iSysDeiversService.getOne(sysDeiversLambdaQueryWrapper);
        final LambdaQueryWrapper<AdviseTransport> sysLogisticsXxljobLambdaQueryWrapper = new LambdaQueryWrapper<>();
        sysLogisticsXxljobLambdaQueryWrapper.eq(AdviseTransport::getState,6);
        sysLogisticsXxljobLambdaQueryWrapper.eq(AdviseTransport::getDeiversId,sysDeivers.getId());
        List<AdviseTransport> list = iAdviseTransportService.list(sysLogisticsXxljobLambdaQueryWrapper);
        if(CollectionUtil.isNotEmpty(list)){
            for (AdviseTransport adviseTransport : list) {
                SysManufacturer manufacturer = iSysManufacturerService.getById(adviseTransport.getManufacturerId());
                adviseTransport.setSysManufacturer(manufacturer);
                SysCrop sysCrop = iSysCropService.getById(adviseTransport.getCropId());
                adviseTransport.setDbSysCrop(sysCrop);
            }

        }
        return list;
    }

    /**
     * 司机接单方法
     * @return
     */
    @RequestMapping("takeOrders")
    public String takeOrders(String logisticsNumber,Integer cropId){
        //根据物流单号查询物流表
        LambdaQueryWrapper<SysLogistics> sysLogisticsLambdaQueryWrapper = new LambdaQueryWrapper<>();
        sysLogisticsLambdaQueryWrapper.eq(SysLogistics::getLogisticsNumber,logisticsNumber);
        SysLogistics sysLogistics = iSysLogisticsService.getOne(sysLogisticsLambdaQueryWrapper);
        //修改司机的状态

        //修改物流表的状态为运输中
        sysLogistics.setState(3);
        iSysLogisticsService.updateById(sysLogistics);
        SysLogisticsXxljob sysLogisticsXxljob = BeanUtil.copyProperties(sysLogistics, SysLogisticsXxljob.class);
        iSysLogisticsXxljobService.updateById(sysLogisticsXxljob);
        //修改完物流表在修改通知物流表的状态为运输中
        LambdaQueryWrapper<AdviseTransport> adviseTransportLambdaQueryWrapper = new LambdaQueryWrapper<>();
        adviseTransportLambdaQueryWrapper.eq(AdviseTransport::getCropId,cropId);
        adviseTransportLambdaQueryWrapper.eq(AdviseTransport::getState,6);
        AdviseTransport adviseTransport = iAdviseTransportService.getOne(adviseTransportLambdaQueryWrapper);
        SysDeivers sysDeiversServiceById = iSysDeiversService.getById(adviseTransport.getDeiversId());

        sysDeiversServiceById.setState(2);
        iSysDeiversService.updateById(sysDeiversServiceById);
        SysCrop sysCrop = iSysCropService.getById(cropId);
        sysCrop.setSysTypeState(3);
        iSysCropService.updateById(sysCrop);
        return "success";
    }

    //司机订单完成方法
    @RequestMapping("orderFulfillment")
    public String orderFulfillment(String logisticsNumber,Integer cropId){
        //根据物流表中的物流编号去查询数据
        LambdaQueryWrapper<SysLogistics> sysLogisticsLambdaQueryWrapper = new LambdaQueryWrapper<>();
        sysLogisticsLambdaQueryWrapper.eq(SysLogistics::getLogisticsNumber,logisticsNumber);
        SysLogistics sysLogistics = iSysLogisticsService.getOne(sysLogisticsLambdaQueryWrapper);
        //修改物流表的状态为已运输
        sysLogistics.setState(7);
        iSysLogisticsService.updateById(sysLogistics);
        SysLogisticsXxljob sysLogisticsXxljob = BeanUtil.copyProperties(sysLogistics, SysLogisticsXxljob.class);
        iSysLogisticsXxljobService.updateById(sysLogisticsXxljob);
        //在修改通知物流表里的状态为已运输
        LambdaQueryWrapper<AdviseTransport> adviseTransportLambdaQueryWrapper = new LambdaQueryWrapper<>();
        adviseTransportLambdaQueryWrapper.eq(AdviseTransport::getCropId,cropId);
        adviseTransportLambdaQueryWrapper.eq(AdviseTransport::getState,6);
        AdviseTransport adviseTransport = iAdviseTransportService.getOne(adviseTransportLambdaQueryWrapper);
        adviseTransport.setState(7);
        iAdviseTransportService.updateById(adviseTransport);
        SysDeivers sysDeiversServiceById = iSysDeiversService.getById(adviseTransport.getDeiversId());
        sysDeiversServiceById.setState(1);
        iSysDeiversService.updateById(sysDeiversServiceById);
        //根据前端传过来的作物id修改作物表的状态为已出售
        SysCrop sysCrop = iSysCropService.getById(cropId);
        sysCrop.setSysTypeState(2);
        iSysCropService.updateById(sysCrop);
        final LambdaQueryWrapper<SysGoods> sysGoodsLambdaQueryWrapper = new LambdaQueryWrapper<>();
        sysGoodsLambdaQueryWrapper.eq(SysGoods::getCropNumbering,sysCrop.getCropNumbering());
        SysGoods dbgoods = iSysGoodsService.getOne(sysGoodsLambdaQueryWrapper);
        if(dbgoods!=null){
            SysGoods sysGoods = BeanUtil.copyProperties(dbgoods, SysGoods.class);
            sysGoods.setSysTypeState(2);
            iSysGoodsService.updateById(sysGoods);
            return "success";
        }
        SysGoods sysGoods = BeanUtil.copyProperties(sysCrop, SysGoods.class);
        sysGoods.setSysTypeState(2);
        iSysGoodsService.save(sysGoods);
        return "success";
    }

    /**
     * 上架列表
     * @return
     */
    @RequestMapping("shangjiaList")
    public List<SysGoods> shangjiaList(){
        List<SysGoods> list=iSysGoodsService.listAll();
        return list;
    }
//编辑上架列表中的单个数据
    @RequestMapping("updateGoods")
    public String updateGoods(@RequestBody SysGoods sysGoods){
        iSysGoodsService.updateById(sysGoods);
        return "success";
    }
    //上架方法
    @RequestMapping("shangjia")
    public String shangjia(Integer id){
        SysGoods sysGoods = iSysGoodsService.getById(id);
        sysGoods.setSysTypeState(1);
        sysGoods.setCreateTime(new Date());
        iSysGoodsService.updateById(sysGoods);
        return "success";
    }

    /**
     * 商品列表
     * @param pageBean
     * @return
     */
    @RequestMapping("goodsList")
    public PageInfo<SysGoods> goodsList(@RequestBody PageBean pageBean){
        PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize());
        List<SysGoods> goodsList=iSysGoodsService.goodsList();
        final PageInfo<SysGoods> sysGoodsPageInfo = new PageInfo<>(goodsList);
        return sysGoodsPageInfo;
    }
 /*   *//*购买方法*//*
    @RequestMapping("buyGoods")
    public String buyGoods(Integer id){
        SysGoods sysGoods = iSysGoodsService.getById(id);
        final LambdaQueryWrapper<PayPlan> payPlanLambdaQueryWrapper = new LambdaQueryWrapper<>();
        payPlanLambdaQueryWrapper.eq(PayPlan::getProductId,sysGoods.getCropNumbering());
        final PayPlan pa = iPayPlanService.getOne(payPlanLambdaQueryWrapper);
        if(pa==null){
            PayPlan payPlan = new PayPlan();
            payPlan.setState(1);
            payPlan.setCreateTime(new Date());
            payPlan.setName(sysGoods.getCropName());
            payPlan.setPrice(sysGoods.getPrice());
            payPlan.setProductId(sysGoods.getCropNumbering());
            payPlan.setOutTradeNo(IdUtil.getSnowflake().nextIdStr());
            iPayPlanService.save(payPlan);
            return "success";
        }
        return "error";
    }*/

    @RequestMapping("orderList")
    public PageInfo<PayPlan> orderList(@RequestBody PageBean pageBean){
        PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize());
        List<PayPlan> list=iPayPlanService.orderList();
        final PageInfo<PayPlan> payPlanPageInfo = new PageInfo<>(list);
        return payPlanPageInfo;
    }
//根据前端传过来的编号查看周期}
////根据前端传过来的编号查看周期记录记录
    @RequestMapping("handleClick")
    public List<CycleCord> handleClick(String cropNumbering){
        LambdaQueryWrapper<CycleCord> cycleCordLambdaQueryWrapper = new LambdaQueryWrapper<>();
        cycleCordLambdaQueryWrapper.eq(CycleCord::getCropNumbering,cropNumbering);
        final List<CycleCord> list = iCycleCordService.list(cycleCordLambdaQueryWrapper);
        return list;
    }
    //下架方法
    @RequestMapping("xiajia")
    public String xiajia(Integer id){
        SysGoods sysGoods = iSysGoodsService.getById(id);
        sysGoods.setSysTypeState(2);
        iSysGoodsService.updateById(sysGoods);
        return "success";
    }
    //根据用户id获取订单列表
    @RequestMapping("orderListByUserId")
    public PageInfo<PayPlan> orderListByUserId(Integer userId,@RequestBody PageBean pageBean){
        PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize());
        List<PayPlan> list = iPayPlanService.orderListByUserId(userId);
        PageInfo<PayPlan> payPlanPageInfo = new PageInfo<>(list);
        return payPlanPageInfo;
    }
    @RequestMapping("goodsList2")
    public List<SysGoods> goodsList2(){
        final List<SysGoods> list = iSysGoodsService.list();
        return list;
    }
}
